class Solution(object):
    def minimumPerimeter(self, neededApples):
        base = int((neededApples // 4) ** (1 / 3))
        while True:
            if 2 * base * (base + 1) * (2 * base + 1) >= neededApples:
                return 8 * base
            else:
                base += 1
